package com.atguigu.patterns.composite;

import java.util.ArrayList;
import java.util.List;

public class College extends Component {

	//List 中 存放的Department
	List<Component> organizationComponents = new ArrayList<>();

	// 构造器
	public College(String name, String des) {
		super(name, des);
			}

	// 重写add
	@Override
	protected void add(Component organizationComponent) {
				//  将来实际业务中，Colleage 的 add 和  University add 不一定完全一样
		organizationComponents.add(organizationComponent);
	}

	// 重写remove
	@Override
	protected void remove(Component organizationComponent) {
				organizationComponents.remove(organizationComponent);
	}

	@Override
	public String getName() {
				return super.getName();
	}

	@Override
	public String getDes() {
				return super.getDes();
	}

	// print方法，就是输出University 包含的学院
	@Override
	protected void print() {
				System.out.println("--------------" + getName() + "--------------");
		//遍历 organizationComponents 
		for (Component organizationComponent : organizationComponents) {
			organizationComponent.print();
		}
	}


}
